/*
 * Copyright 2010 Christian Matzat and others
 *
 *    Licensed under the Apache License, Version 2.0 (the "License");
 *    you may not use this file except in compliance with the License.
 *    You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *    Unless required by applicable law or agreed to in writing, software
 *    distributed under the License is distributed on an "AS IS" BASIS,
 *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *    See the License for the specific language governing permissions and
 *    limitations under the License.
 */

package net.matzat.android.hiberdroid.mapping;

/**
 * This Object hold the mapping for each mapped column of an entity
 */
public class ColumnMapping {

    private String column;
    private ColumnType columnType;
    private boolean isId;
    private boolean autoincrement;

    /**
     * Create a new column mapping.
     *
     * @param column        column name at the database
     * @param columnType    database type of this column
     * @param isId          is this column the isId column
     * @param autoincrement if isId column, should autoincrement switched on
     */
    public ColumnMapping(String column, ColumnType columnType, boolean isId, boolean autoincrement) {
        this.column = column;
        this.columnType = columnType;
        this.isId = isId;
        this.autoincrement = autoincrement;
    }

    /**
     * Gets the database column name of this column at the database.
     *
     * @return the database column name
     */
    public String getColumn() {
        return column;
    }

    /**
     * Gets the database type of this column at the database.
     *
     * @return
     */
    public ColumnType getColumnType() {
        return columnType;
    }

    /**
     * Is this column the isId column.
     *
     * @return true if column is isId column
     */
    public boolean isId() {
        return isId;
    }

    /**
     * If this column is isId column, is autoincrement switched on.
     *
     * @return true if column is isId column and autoincrement is switched on
     */
    public boolean isAutoincrement() {
        return isId && autoincrement;
    }
}